package imoney.server;

import imoney.server.util.CookieBuilderServer;

import java.io.IOException;

import javax.servlet.Servlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CookieServlet extends HttpServlet implements Servlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp) {
		System.out.println();
		for (Cookie c : req.getCookies()){
			System.out.println("req cookie name : " + c.getName());
			//System.out.println("req cookie value : " + c.getValue());
			System.out.println("req cookie domain : "+ c.getDomain());
			System.out.println("----------");
		}
		
		Cookie cookie = new Cookie("cogno", "still waiting for the BK");
		cookie.setPath("/");
		resp.addCookie(cookie);
		try {
			resp.getWriter().write("Adding words to the resp before redirecting");
			resp.sendRedirect("/auth/IMoney.html");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
